| Conditions | 1 |
| Paths | 18 |
| Total Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 10 |
| CRAP Score | 1.0007 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | /** |
||
| 13 | 1 | const register = (server, opts, next) => { |
|
| 14 | 1 | const options = Object.assign({}, defaultOptions, opts); |
|
| 15 | 1 | options.excludeUrlPatterns.push(new RegExp(`/${URL_CHANGE_PASSWORD}`)); |
|
| 16 | 1 | server.ext('onPostAuth', (request, reply) => { |
|
| 17 | 13 | const isApi = request.path.includes(options.apiPrefix); |
|
| 18 | 13 | const isExcludedUrl = options.excludeUrlPatterns.some(pattern => pattern.test(request.path)); |
|
| 19 | 13 | const isTemporaryUser = request.auth && request.auth.credentials && request.auth.credentials.isTemporary; |
|
| 20 | 13 | if (!isApi && !isExcludedUrl && isTemporaryUser) { |
|
| 21 | return reply.redirect(`/${URL_CHANGE_PASSWORD}?redirect=${request.path || '/'}`); |
||
| 22 | } |
||
| 23 | 13 | return reply.continue(); |
|
| 24 | }); |
||
| 25 | 1 | next(); |
|
| 26 | }; |
||
| 27 | |||
| 34 |